using System.IO;
using System.Windows.Forms;

namespace DeVierKoeden.Dynamicweb.CreateSite
{
  internal class FileExplorer
  {
    public void CreateTree(TreeView treeView, string path)
    {
      // Create Desktop
      var root = new TreeNode
      {
        Text = "Site",
        Tag = path
      };
      root.Nodes.Add("");
      treeView.Nodes.Add(root);
    }

    public TreeNode EnumerateDirectory(TreeNode parentNode)
    {
      var rootDir = new DirectoryInfo(parentNode.Tag.ToString());
      parentNode.Nodes[0].Remove();
      foreach (var dir in rootDir.GetDirectories())
      {
        var node = new TreeNode { Text = dir.Name, Tag = dir.FullName };
        node.Nodes.Add("");
        parentNode.Nodes.Add(node);
      }
      return parentNode;
    }
  }
}
